home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / PDraw3.0.adf / pdraw_rex.lzh / Mandela.pdrx < prev    next >
Text File  |  1992-06-15  |  2KB  |  94 lines

  1. /*
  2. @N
  3.  
  4. This Genie will draw connected polygons on the screen
  5. */
  6.  
  7. msg = PDSetup.rexx(2,0)
  8. units = getclip(pds_units)
  9. if msg ~= 1 then exit_msg(msg)
  10.  
  11. numeric digits 8
  12.  
  13. pi2 = 6.28318
  14. cr = '0a'x
  15.  
  16. custom = pdm_inform(2,"Select Base Shape","Circle","Custom")
  17.  
  18. if custom = 0 then do
  19.  
  20.    man = pdm_getform("Enter mandela info",4,"sides"cr"radius")
  21.    if man = '' then exit_msg()
  22.    parse var man order '0a'x radius
  23.  
  24.     if ~(datatype(order, n) & datatype(radius, n)) then
  25.         exit_msg("Invalid Entry")
  26.  
  27.    if units > 2 then radius = pdm_ConvertUnits(units,1, radius)
  28.    ang = pi2 / order
  29.  
  30.    posn = pdm_clickellipse("where eh?",radius,radius)
  31.  
  32.    call pdm_initplot(word(posn,1),word(posn,2),1,1,0)
  33.    do steps = 0 to order-1
  34.        theta = ang * steps
  35.        x = cos(theta) * radius
  36.        y = sin(theta) * radius
  37.        plotline(x" "y)
  38.    end
  39.    obj = pdm_closeplot()
  40. end
  41. else 
  42. do
  43.     obj = pdm_clickonobj("Select the custom object")
  44.     if obj = 0 then exit_msg()
  45. end
  46.  
  47.  
  48. /* draw the stars to complete the above object */
  49.  
  50. order  = pdm_getobjorder(obj)
  51. if pdm_isclosed(obj) then order = order - 1
  52. if custom = 1 then first = 1
  53.               else first = 2
  54. do star = first to order / 2
  55.     min = order
  56.     anchor = 0
  57.     point = subword(pdm_getpoint(obj,anchor),1,2)
  58.     call pdm_initplot()
  59.     plotline(point)
  60.     p2 = (anchor + star) // order
  61.     do while p2 ~= anchor
  62.         if p2 < min then min = p2
  63.         point = subword(pdm_getpoint(obj,p2),1,2)
  64.         plotline(point)
  65.         p2 = (p2 + star) // order
  66.     end
  67.     call pdm_closeplot()
  68.  
  69.     do anchor = 1 to min - 1
  70.        point = subword(pdm_getpoint(obj,anchor),1,2)
  71.        call pdm_initplot()
  72.        plotline(point)
  73.        p2 = (anchor + star) // order
  74.        do while p2 ~= anchor
  75.            point = subword(pdm_getpoint(obj,p2),1,2)
  76.            plotline(point)
  77.            p2 = (p2 + star) // order
  78.        end
  79.        call pdm_closeplot()
  80.     end
  81.     call pdm_updatescreen(1)
  82. end
  83.  
  84. exit_msg()
  85.  
  86. exit_msg: procedure expose units
  87. do
  88.     parse arg message
  89.  
  90.     if message ~= '' then call pdm_Inform(1,message,)
  91.     call pdm_SetUnits(units)
  92.     exit
  93. end
  94.